package com.ums.upos;

import android.content.Context;

import com.nexgo.oaf.apiv3.DeviceEngine;
import com.nexgo.oaf.apiv3.device.pinpad.PinKeyboardModeEnum;
import com.nexgo.oaf.apiv3.device.pinpad.PinPad;
import com.nexgo.oaf.apiv3.hsm.HSMDevice;
import com.ums.upos.service.IccReaderHolder;
import com.ums.upos.uapi.device.beeper.Beeper;
import com.ums.upos.uapi.engine.LanguageType;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by xiaox on 16/9/18.
 */
public class GlobalDataHolder {

    private static Context context;

    public void setContext(Context context){
        this.context = context;
    }

    public Context getContext(){
        return context;
    }

    public boolean isSupportChnCryptAlg() {
        return isSupportChnCryptAlg;
    }

    public void setSupportChnCryptAlg(boolean supportChnCryptAlg) {
        isSupportChnCryptAlg = supportChnCryptAlg;
    }

    public PinPad getSdkPinpad() {
        if(null == sdkPinpad)
            sdkPinpad = deviceEngine.getPinPad();
        return sdkPinpad;
    }

    public void setSdkPinpad(PinPad sdkPinpad) {
        this.sdkPinpad = sdkPinpad;
    }

    public HSMDevice getSdkHSMDevice() {
        if(null == sdkHSMDevice)
            sdkHSMDevice = deviceEngine.getHSMDevice();
        return sdkHSMDevice;
    }

    public String getTidsn() {
        return tidsn;
    }

    public void setTidsn(String tidsn) {
        this.tidsn = tidsn;
    }

    public int getLanguageType() {
        return languageType;
    }

    public void setLanguageType(int languageType) {
        this.languageType = languageType;
    }

    public Beeper getBeeper() {
        return beeper;
    }

    public void setBeeper(Beeper beeper) {
        this.beeper = beeper;
    }

    public boolean isSupportDotMatrix() {
        return isSupportDotMatrix;
    }

    public void setSupportDotMatrix(boolean supportDotMatrix) {
        isSupportDotMatrix = supportDotMatrix;
    }

    public boolean isRFActive() {
        return isRFActive;
    }

    public void setRFActive(boolean RFActive) {
        isRFActive = RFActive;
    }

    public boolean isSupportGetRfCardInfo() {
        return isSupportGetRfCardInfo;
    }

    public void setSupportGetRfCardInfo(boolean supportGetRfCardInfo) {
        isSupportGetRfCardInfo = supportGetRfCardInfo;
    }

    public boolean isSupportWifiProbe() {
        return isSupportWifiProbe;
    }

    public void setSupportWifiProbe(boolean supportWifiProbe) {
        isSupportWifiProbe = supportWifiProbe;
    }

    public String getSn() {
        return sn;
    }

    public void setSn(String sn) {
        this.sn = sn;
    }

    private static class InstanceHolder {
        static final GlobalDataHolder VALUE = new GlobalDataHolder();
    }

    public static GlobalDataHolder getInstance() {
        return InstanceHolder.VALUE;
    }

    private String bussinessId;
    private int workMode;
    private List<IccReaderHolder> iccReaderHolderList = new ArrayList<>();
    private DeviceEngine deviceEngine;
    private String showAmount;
    private PinPad sdkPinpad;
    private HSMDevice sdkHSMDevice;
    private boolean isSupportScrpitPrint;
    private boolean isSupportChnCryptAlg;
    private boolean isSupportDotMatrix;
    private boolean isSupportGetRfCardInfo;
    private boolean isSupportWifiProbe = false;
    private String sn;
    private String tidsn;
    private int languageType = LanguageType.SIMPLIFIED_CHINESE;
    private Beeper beeper;
    private boolean isRFActive;//mhl20171019 新增非接卡片激活标识，防止重复激活
    private Logger log = LoggerFactory.getLogger("GLOBALDATAHOLDER");

    public String getShowAmount() {
        String amount = showAmount;
        showAmount = null;
        return amount;
    }

    public void setShowAmount(String showAmount) {
        this.showAmount = showAmount;
        log.debug("GlobalDataHolder showAmount Updated! showAmount：{}",this.showAmount);
    }

    public String getBussinessId() {
        return bussinessId;
    }

    public void setBussinessId(String bussinessId) {
        this.bussinessId = bussinessId;
    }

    public int getWorkMode() {
        return workMode;
    }

    public void setWorkMode(int workMode) {
        this.workMode = workMode;
    }

    public List<IccReaderHolder> getIccReaderHolderList() {
        return iccReaderHolderList;
    }

    public DeviceEngine getDeviceEngine() {
        return deviceEngine;
    }

    public void setDeviceEngine(DeviceEngine deviceEngine) {
        this.deviceEngine = deviceEngine;
    }

    public boolean isSupportScrpitPrint() {
        return isSupportScrpitPrint;
    }

    public void setSupportScrpitPrint(boolean supportScrpitPrint) {
        isSupportScrpitPrint = supportScrpitPrint;
    }
}
